package personal.lijun.skeleton.springcloud.common.data;

/**
 * @Auther: lijun@sstcsoft.com
 * @Date: 2019/9/12 17:28
 */
public class ApiResultPrimitiveValue<T extends Number>{
    private T value;
    //执行代码
    private int code;
    //详细错误日志
    private String message;
    //日志异常栈信息
    private String stackTrace;

    public ApiResultPrimitiveValue(){
        this.code = ApiResultSet.SUCCESS;
    }

    public ApiResultPrimitiveValue(T value){
        this.code = ApiResultSet.SUCCESS;
        this.value = value;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getStackTrace() {
        return stackTrace;
    }

    public void setStackTrace(String stackTrace) {
        this.stackTrace = stackTrace;
    }

    public T getValue() {
        return value;
    }

    public void setValue(T value) {
        this.value = value;
    }

    public String toFullMessage(){
        StringBuilder sb = new StringBuilder();
        sb.append("调用远程服务出错，错误代码："+ code);
        sb.append("\r\n");
        sb.append(message);
        sb.append("\r\n");
        sb.append(stackTrace);
        return sb.toString();
    }
}
